package com.hgy.plugin.security.tag;

import org.apache.shiro.subject.Subject;
import org.apache.shiro.web.tags.PermissionTag;

public class HasAllPermissionsTag extends PermissionTag {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	private static final String PERMISSION_NAMES_DELIMITER = ",";

	@Override
	protected boolean showTagBody(String permissionNames) {
		boolean hasAllPermission = false;
		
		Subject subject = getSubject();
		if(subject != null){
			if(subject.isPermittedAll(permissionNames.split(PERMISSION_NAMES_DELIMITER))){
				hasAllPermission = true;
			}
		}
		return hasAllPermission;
	}
}
